IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'spFiles_Create')
	BEGIN
		PRINT 'Dropping Procedure spFiles_Create'
		DROP  Procedure  spFiles_Create
	END

GO

PRINT 'Creating Procedure spFiles_Create'
GO
CREATE Procedure dbo.spFiles_Create
	( 	  
	  @BoxNo varchar(50) = null, 
		@DivisionName varchar(50) = null, 
		@DepartmentName varchar(50) = null, 
		@CategoryName varchar(50) = null, 
		@ProductName varchar(50) = null, 
		@Archive_ID int = null, 
		@FileStatus varchar(50) = null, 
		@Notes varchar(250) = null, 
		@Description varchar(100) = null, 
		@FromNo int = null, 
		@ToNo int = null, 
		@FromDate DateTime = null, 
		@ToDate DateTime = null, 
		@FromAlpha varchar(50) = null, 
		@ToAlpha varchar(50) = null, 
		@CreatedDate DateTime = null, 
		@CreatedByUser_ID numeric(9,0) = null, 
		@Request_ID int = null, 
		@RequestDate DateTime = null, 
		@RequestedByUser_ID numeric(9,0) = null, 
		@RequestedDate DateTime = null
	)
AS
  /* 
    ------------------------------------------------------------------------------
    - Change History
    - --------------
    - Date          Description
    ------------------------------------------------------------------------------
    - 2007/11/02    Initial version created
    ------------------------------------------------------------------------------
  */

	-- Declare the required variables

	-- Create the required new record
	INSERT INTO Files
	  (
		BoxNo,
			DivisionName,
			DepartmentName,
			CategoryName,
			ProductName,
			Archive_ID,
			FileStatus,
			Notes,
			Description,
			FromNo,
			ToNo,
			FromDate,
			ToDate,
			FromAlpha,
			ToAlpha,
			CreatedDate,
			CreatedByUser_ID,
			Request_ID,
			RequestDate,
			RequestedByUser_ID,
			RequestedDate	  
	  )
	VALUES
	  (
		@BoxNo,
			@DivisionName,
			@DepartmentName,
			@CategoryName,
			@ProductName,
			@Archive_ID,
			@FileStatus,
			@Notes,
			@Description,
			@FromNo,
			@ToNo,
			@FromDate,
			@ToDate,
			@FromAlpha,
			@ToAlpha,
			@CreatedDate,
			@CreatedByUser_ID,
			@Request_ID,
			@RequestDate,
			@RequestedByUser_ID,
			@RequestedDate
	  )

	-- Handle any errors
	IF @@ERROR != 0
	BEGIN
		RAISERROR('spFiles_Create: Unable to Insert a new Files', 10, 1)
		RETURN
	END

	-- Return the newly created ID
	SELECT	@@IDENTITY AS 'Files_ID'

	-- Return to calling method
	RETURN 

GO
